home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: IBMailTo.thor v1.1 (14/08/96) John S. Burger. ** <jsburger@xmission.com> ** ** This script borrows heavily from AwebMailTo.thor by Shaun Downend. ** <shaund@amiganut.demon.co.uk> ** Thanks Shaun!!! ** ** This script is designed for use with IBrowse's external mailto: support. ** It will take the email address supplied by IBrowse and start the text ** editor of your choice and automatically fill in the To: field. When you ** have finished you save the message and it will appear as an event in Thor. ** ** See the .readme file for configuration information. */ /* User defined variables */ MailSystem = 'Internet' /* Set to your TCP System in Thor */ MailConfName = 'EMail' /* Set to your Email Conference in Thor */ AddSignature = 'E' /* Add signature (Y/N/E) from Thor or 'E' for another signature file*/ SigFile = 'DH3:Thor/IB.signature' /* File name with path for a signature file used with the 'E' option above */ SendEvent = 'N' /* Send event immediately (Y/N) */ Editor = 'GED -STICKY C=DH1:GoldEd/config/IB.prefs' /* Set to the editor of your choice */ /* DON'T CHANGE ANYTHING BELOW HERE */ Tempfile = 't:MailTo.msg.'||time(s)'.ib' parse arg argument template = 'ADDRESS/A' if(argument = '' | argument = '?') then do say '$VER: IBMailTo.thor V1.0 (13/08/96) John S. Burger' say 'Template:' template exit end if ~show('p', 'BBSREAD') then do address command "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead" "sys:rexxc/WaitForPort BBSREAD" end address BBSREAD READARGS template ARGS CMDLINE argument if(rc ~= 0) then do say BBSREAD.LASTERROR exit end address command 'echo >'tempfile' "To: 'ARGS.ADDRESS'*NSubject: *N"' address command ''Editor' 'tempfile'' if(~OPEN(fh,tempfile,'Read')) then do say 'Unable to open file' exit end str = readln(fh) if(upper(word(str, 1)) ~= "TO:") then do call showerror("First headerline wasn't a To:, please don't mess with the header IBrowse provides.") call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end else EVENT.TOADDR = word(str, 2) str = readln(fh) if(upper(word(str, 1)) ~= "SUBJECT:") then do call showerror("Second headerline wasn't a Subject:, please don't mess with the header IBrowse provides.") call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end else EVENT.SUBJECT = substr(str, 10) if(upper(word(str, 2)) = "") then do call showerror("Mail Discarded by User") call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end /* skip X-Mailer: line */ call readln(fh) /* put the body of the message in a file with a unique name */ UNIQUEMSGFILE bbsname '"'MailSystem'"' stem UNIQUEFILE if(rc ~= 0) then do call showerror('UNIQUEMSGFILE BBSRead command failed: ' || BBSREAD.LASTERROR) call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end call open(tmp, UNIQUEFILE.NAME, W) do until eof(fh) call writeln(tmp, readln(fh)) end /* add signature from the EMail conference/BBS/Global Settings */ if(upper(AddSignature) = 'Y') then do GETCONFDATA BBSNAME '"'MailSystem'"' CONFNAME '"'MailConfName'"' STEM CONFD if(CONFD.SIGNATURE = "") then do GETBBSDATA BBSNAME '"'MailSystem'"' STEM BBSD if(BBSD.SIGNATURE = "") then do GETGLOBALDATA STEM GLOBD if(GLOBD.SIGNATURE = "") then do call showerror('No signature configured in either conference, bbs or global settings! Please correct this in THOR or turn off signature adding in IBMailTo.thor.') call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end else sig = GLOBD.SIGNATURE end else sig = BBSD.SIGNATURE end else sig = CONFD.SIGNATURE drop CONFD.; drop BBSD.; drop GLOBD. if(sig ~= "") then do /* signature may be a filename */ if(exists(sig)) then do call open(sigfh, sig, R) do until eof(sigfh) call writeln(tmp, readln(sigfh)) end call close(sigfh) end else call writeln(tmp, sig) /* or just a string */ end end if(upper(AddSignature) = 'E') then do if(exists(SigFile)) then do call open(sigfh, SigFile, R) do until eof(sigfh) call writeln(tmp, readln(sigfh)) end call close(sigfh) end else do call showerror('The configured signature file does not exist! Please correct this or turn off signature adding in IBMailTo.thor.') call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end end call close(tmp) /* fill out some more variables that BBSREAD require */ EVENT.CONFERENCE = MailConfName EVENT.MSGFILE = UNIQUEFILE.FILEPART /* write the event */ WRITEBREVENT bbsname '"'MailSystem'"' event 0 stem EVENT if(rc ~= 0) then do call showerror('WRITEBREVENT BBSRead command failed: ' || BBSREAD.LASTERROR) call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end call close(fh) address command 'c:delete >NIL: 'tempfile'' if upper(sendevent) = "Y" then call send exit 0 /* sophisticated errorhandling :-) */ showerror: procedure expose MailSystem MailConfName AddSignature SigFile Editor parse arg errormsg p=show('P',,) if(pos('IBROWSE', p) > 0) then IBport = word(substr(p, pos('IBROWSE', p)), 1) else return call open(err, "T:IBMailTo.thor.error.html", W) call writeln(err, "<HTML><HEAD><TITLE>IBMailTo.thor encountered an error</TITLE></HEAD><BODY><H1>Sending mail aborted</H1>" || errormsg || "<P>Please remember to verify the following settings:<PRE>" || '0a'x '0a'x || "MailSystem = '" || MailSystem || "'" || '0a'x || "MailConfName = '" || MailConfName || "'" || '0a'x || "AddSignature = '" || AddSignature || "'" || '0a'x || "SigFile = '" || SigFile || "'" || '0a'x || "Editor = '" || Editor || "'" || '0a'x '0a'x || "</PRE>If they are wrong, edit IBMailTo.thor and correct them. <hr> If this should happen to be an erroneous error, don't hesitate to contact the author, John S. Burger, by <A HREF=" || '"' || "mailto:jsburger@xmission.com" || '"' || ">email</A>.") call close(err) address(IBport) 'GOTOURL URL file://localhost/T:IBMailTo.thor.error.html' return send: If Show('p', 'AMITCP') | Show('p', 'MIAMI.1') = 1 then do address BBSREAD GETBBSDATA SystemName stem BBSDATA if BBSDATA.NUMEVENTS ~= 0 then address command 'run >NIL: `getenv thor/thorpath`bin/SendTCP 'MailSystem' pubscreen=Workbench' end return